<?php
require_once 'config.php';
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" type="text/css" href="style.css" />
    <title><?php echo $title; ?></title>
</head>

<body>
    <div class="box">
        <h1><?php echo $title; ?></h1>
        <div class="content">
            <p class="input">
                <a href="text.php" class="button">我要许愿</a>
            </p>
            <ul>
                <?php
                // 最新留言展示前面
                $sql = "SELECT * FROM `wish` ORDER BY `wish`.`id` DESC";
                $result = $conn->query($sql);

                if ($result->num_rows > 0) {
                    // 输出数据
                    while ($row = $result->fetch_assoc()) {
                ?>

                        <li class="sss" style="background: <?php echo $row["color"] ?>;">
                            <p class="border">
                                <?php echo $row["name"]; ?>
                            </p>
                            <p><?php echo $row["content"]; ?></p>
                            <p><?php echo $row["time"]; ?></p>
                            <p class="b">
                                <a href="edit.php?id=<?php echo $row['id']; ?>">编辑</a>
                                <a href="del.php?id=<?php echo $row['id']; ?>">删除</a>
                            </p>
                        </li>

                <?php
                    }
                } else {
                    echo "暂无心愿留言";
                }
                ?>
            </ul>

            <div class="footer">—————————— END ——————————</div>
        </div>
    </div>
</body>

</html>